import {Notification} from 'element-ui'
import {MessageBox} from 'element-ui'
export default {
  success: function (msg) {
    Notification.success({
      title: '成功',
      message: msg,
      duration: 2000,
      customClass: 'successClass'
    })
  },
  warning: function (msg) {
    Notification.warning({
      title: '警告',
      message: msg,
      duration: 2000,
      customClass: 'warningClass'
    })
  },
  info: function (msg) {
    Notification.info({
      title: '消息',
      message: msg,
      duration: 2000,
      customClass: 'infoClass'
    })
  },
  error: function (msg) {
    Notification.error({
      title: '错误',
      message: msg,
      duration: 2000,
      customClass: 'errorClass'
    })
  },
  confirm: function (...args) {
    MessageBox.confirm(args[0], '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
      customClass: 'confirmClass'
    }).then(() => {
      // 确定是否回调
      if (args[1]) {
        args[1](true)
      } else {
        // 一个参确定
        // console.log('1')
      }
    }).catch(() => {
      if (args[2]) {
        args[2]()
        console.log('4')
      } else {
        // 取消
      }
    })
  },
  //提交内容
  prompt: function (...args) {
    MessageBox.prompt(args[0], '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then((value) => {
      if (args[1]) {
        args[1](value.value)
      }
    }).catch(() => {
      if (args[2]) {
        args[2]()
      }
    })
  }
}